package com.fintecher.controller;

import com.fintecher.pojo.Sellers;
import com.fintecher.service.ISellersService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/sellers")
public class SellersController {

    @Resource
    private ISellersService sellersService;

    //首页  点击login.jsp “提交” 到首页并 获取首页卖方市场的产品列表
    @RequestMapping(value="getSellersList")
    public String getSellersList(HttpServletRequest request, Model model) {
       List<Sellers> lists = this.sellersService.getSellersList();
        model.addAttribute("lists", lists);
        //控制main.jsp中的属性
        model.addAttribute("main_sell_class","active");
        model.addAttribute("main_buy_class","");

        return "/main";
    }
    //票据行情  点击main.jsp中的“票据行情” 跳转并获取卖方市场的产品列表菜单部分（并加载主体部分）
    @RequestMapping(value="getSellersList2")
    public String getSellersList2(HttpServletRequest request, Model model) {

        //用来改变bill_market.jsp中的属性
        model.addAttribute("sell_active_class","active user-mes");
        model.addAttribute("buy_active_class","");
        model.addAttribute("iframe_src",request.getContextPath()+"/sellers/sell_market");

        //用来携带登录用户名在右上方显示
        model.addAttribute("companyName",request.getSession().getAttribute("companyName"));

        return "/bill_market";
    }



    //票据行情  点击卖方市场跳转到sell_market.jsp（该页面显示卖方产品列表主体内容）
    @RequestMapping(value = "sell_market")
    public String sell_market(HttpServletRequest request, Model model){

        List<Sellers> lists = this.sellersService.getSellersList();
        model.addAttribute("lists", lists);
        return "sell_market";
    }



}



